home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / lisp / ilisp / ilisp-cmt.el.z / ilisp-cmt.el
Encoding:
Text File  |  1998-05-21  |  2.7 KB  |  89 lines

  1. ;;; -*- Mode: Emacs-Lisp -*-
  2.  
  3. ;;; ilisp-cmt.el --
  4.  
  5. ;;; This file is part of ILISP.
  6. ;;; Version: 5.8
  7. ;;;
  8. ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
  9. ;;;               1993, 1994 Ivan Vasquez
  10. ;;;               1994, 1995, 1996 Marco Antoniotti and Rick Busdiecker
  11. ;;;               1996 Marco Antoniotti and Rick Campbell
  12. ;;;
  13. ;;; Other authors' names for which this Copyright notice also holds
  14. ;;; may appear later in this file.
  15. ;;;
  16. ;;; Send mail to 'ilisp-request@naggum.no' to be included in the
  17. ;;; ILISP mailing list. 'ilisp@naggum.no' is the general ILISP
  18. ;;; mailing list were bugs and improvements are discussed.
  19. ;;;
  20. ;;; ILISP is freely redistributable under the terms found in the file
  21. ;;; COPYING.
  22.  
  23.  
  24. ;;;
  25. ;;; ILISP comint interface code.
  26. ;;;
  27. ;;;
  28.  
  29.  
  30. ;;;%Process interface
  31. ;;;%%Comint 
  32. (defun ilisp-get-old-input ()
  33.   "Snarf the sexp starting at the nearest previous prompt, or NIL if none."
  34.   (save-excursion
  35.     (let* ((begin (lisp-defun-begin))
  36.        (pmark (process-mark (get-buffer-process (current-buffer))))
  37.        (once (if (< (point) pmark)
  38.              (save-excursion (end-of-line) (point))))
  39.        (end nil)
  40.        (done nil))
  41.       (condition-case ()
  42.       (while (and (not done) (< (point) (point-max)))
  43.         (forward-sexp)
  44.         (setq end (point))
  45.         (skip-chars-forward " \t\n")
  46.         (if (and once (>= (point) once)) (setq done t)))
  47.     (error (setq end nil)))
  48.       (if end (buffer-substring begin end)))))
  49.  
  50. ;;;
  51. (defun ilisp-input-filter (str)
  52.   "Don't save anything matching ilisp-filter-regexp or less than
  53. ilisp-filter-length long."
  54.   (and (not (string-match ilisp-filter-regexp str))
  55.        (> (length str) ilisp-filter-length)))
  56.  
  57. ;;;
  58. (defun ilisp-error-filter (output)
  59.   "Keep from OUTPUT only what matches ilisp-error-regexp or everything
  60. if there is no match."
  61.   (if (string-match (ilisp-value 'ilisp-error-regexp) output)
  62.       (substring output (match-beginning 0) (match-end 0))
  63.       output))
  64.  
  65.  
  66.  
  67. (defun newline-and-indent-lisp ()
  68.   "If at the end of the buffer, send the string back to the process
  69. mark with no newline.  Otherwise, insert a newline, then indent.  In
  70. an ilisp buffer the region is narrowed first.  See newline-and-indent
  71. for more information."
  72.   (interactive "*")
  73.   (if ilisp-complete
  74.       (exit-minibuffer)
  75.       (let (input)
  76.     (if (and (= (point) (point-max)) 
  77.          (memq major-mode ilisp-modes)
  78.          (setq input (ilisp-get-old-input)))
  79.         (let ((process (ilisp-process))
  80.           (comint-send-newline (not comint-send-newline)))
  81.           (funcall comint-input-sender process input)
  82.           (set-marker (process-mark process) (point)))
  83.         (save-restriction
  84.           (if (memq major-mode ilisp-modes)
  85.           (narrow-to-region (save-excursion (lisp-input-start))
  86.                     (point-max)))
  87.           (newline-and-indent))))))
  88.  
  89.